<?php

declare (strict_types=1);

namespace app\shop\model\shop;


use app\admin\model\Page as PageModel;
use app\admin\model\store\User as StoreUserModel;
use app\common\model\shop\shop\Shop as ShopModel;
use app\common\model\shop\shop\shop\Shop as DetailModel;
use app\shop\controller\Files;
use app\store\model\UploadFile;

/**
 * 商户详细信息模型
 * Class StoreUser
 * @package app\store\model
 */
class Detail extends DetailModel
{
    public static function detail($shopId){
        $shopModel = new ShopModel();
        $shop = $shopModel->get($shopId);
        $detail = self::where('shop_id',$shopId)->field('shop_id,address,shop_category_id,shop_group_id,name,logo_image_id,avatar_image_id,big_image_id,desc,keywords,province_id,city_id,region_id')->find();
        $detail->category = Category::detail($detail->shop_category_id);
        $detail->group = Group::detail($detail->shop_group_id);
        $detail->logo = UploadFile::detail($detail->logo_image_id);
        $detail->avatar = UploadFile::detail($detail->avatar_image_id);
        $detail->big = UploadFile::detail($detail->big_image_id);
        $shop->shopdetail = $detail;
        return $shop;
    }

    public static function address($shopId){
        $shopModel = new ShopModel();
        $shop = $shopModel->get($shopId);
        $detail = self::where('shop_id',$shopId)->field('shop_id,legal_name,legal_mobile,address,province_id,city_id,region_id,qq,wangwang,email,workday,worktime')->find();
        $shop->shopdetail = $detail;
        return $shop;
    }

    public function edit($data){
        return $this->update($data) !== false;
    }
}